package com.sls.web.manager.game.service.impl;

import java.util.UUID;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import com.sls.core.socket.Head;
import com.sls.core.socket.SocketDTO;
import com.sls.core.socket.TransmissionCode;
import com.sls.web.manager.execption.ManagerException;
import com.sls.web.manager.game.pojo.GameSpecialPrice;
import com.sls.web.manager.game.service.LocalGoodsNotice;
import com.sls.web.manager.pojo.UserInfoVO;
import com.sls.web.manager.socket.SuperService;

@Service("localGoodsNotice")
public class LocalGoodsNoticeImpl extends SuperService implements
		LocalGoodsNotice {

	private static Logger log = Logger.getLogger(LocalGoodsNoticeImpl.class);

	/**
	 * 商品变更，主动通知
	 * 
	 * @param goodsId
	 * @throws Exception
	 */
	@Override
	public void noticeGoodsModify(String goodsId, String templateCode,
			UserInfoVO userInfoVO) throws Exception {
		Head head = new Head();
		head.setRequestId(UUID.randomUUID().toString());
		head.setServiceCode("021035");
		head.setIp(userInfoVO.getCurrentIp());
		head.setUserId(userInfoVO.getUserId());

		log.info("请求" + head.getRequestId() + "\n 操作员："
				+ userInfoVO.getUserName() + " 进行商品变更通知操作");
		GameSpecialPrice gsp = new GameSpecialPrice();
		gsp.setGoodsId(goodsId);
		gsp.setTemplateCode(templateCode);
		SocketDTO dto = super.send(head, gsp);
		if (dto != null
				&& dto.getHead() != null
				&& TransmissionCode.SUCCESS.getCode().equals(
						dto.getHead().getResponseCode())) {
		} else {
			throw new ManagerException(dto.getHead().getResponseMessage());
		}
	}

}
